﻿

namespace Cid.Windows.Controls
{
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;
	using System.Windows.Controls;

	using Cid.Models;

	public class ObjectValidationRules : System.Windows.Controls.ValidationRule
	{
		public IEnumerable<IValidationRule> Rules { get; set; }
		

		public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
		{
			if (this.Rules != null)
			{
				foreach (IValidationRule rule in this.Rules)
					if (!rule.Validate(value))
						return new ValidationResult(false, rule.Message);
			}
			return new ValidationResult(true, null);
		}
	}
}
